package Demo603;



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DbUntil {
    // 数据库连接信息
    private static final String URL = "jdbc:mysql://localhost:3306/usersDb";
    private static final String DB_USERNAME = "root";
    private static final String DB_PASSWORD = "123456";

    // 编写一个连接数据库的方法
    public Connection getCon() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(URL, DB_USERNAME, DB_PASSWORD);
        return conn;
    }
}

